package happyhouse.ui.dialogs;

import org.eclipse.swt.widgets.Dialog;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.wb.swt.layout.grouplayout.GroupLayout;

public class LoginDialog extends Dialog {

	protected Object result;
	protected Shell shell;
	private Text text;
	private Text text_1;

	/**
	 * Create the dialog.
	 * @param parent
	 * @param style
	 */
	public LoginDialog(Shell parent, int style) {
		super(parent, style);
		setText("SWT Dialog");
	}

	/**
	 * Open the dialog.
	 * @return the result
	 */
	public Object open() {
		createContents();
		shell.open();
		shell.layout();
		Display display = getParent().getDisplay();
		while (!shell.isDisposed()) {
			if (!display.readAndDispatch()) {
				display.sleep();
			}
		}
		return result;
	}

	/**
	 * Create contents of the dialog.
	 */
	private void createContents() {
		shell = new Shell(getParent(), getStyle());
		shell.setSize(369, 197);
		shell.setText(getText());
		
		Label lblNewLabel = new Label(shell, SWT.NONE);
		lblNewLabel.setText("T\u00EAn \u0111\u0103ng nh\u1EADp");
		
		text = new Text(shell, SWT.BORDER);
		
		Label lblMtKhu = new Label(shell, SWT.NONE);
		lblMtKhu.setText("M\u1EADt kh\u1EA9u");
		
		text_1 = new Text(shell, SWT.BORDER);
		
		Button btnGhiNh = new Button(shell, SWT.CHECK);
		btnGhiNh.setText("Ghi nh\u1EDB");
		
		Label lblNgnNg = new Label(shell, SWT.NONE);
		lblNgnNg.setText("Ng\u00F4n ng\u1EEF");
		
		Combo combo = new Combo(shell, SWT.NONE);
		combo.setItems(new String[] {"Vietnamese", "English", "Japanese"});
		
		Button btnCuHnh = new Button(shell, SWT.NONE);
		btnCuHnh.setText("C\u1EA5u h\u00ECnh");
		
		Button btnngNhp = new Button(shell, SWT.NONE);
		btnngNhp.setText("\u0110\u0103ng nh\u1EADp");
		
		Button btnng = new Button(shell, SWT.NONE);
		btnng.setText("\u0110\u00F3ng");
		GroupLayout gl_shell = new GroupLayout(shell);
		gl_shell.setHorizontalGroup(
			gl_shell.createParallelGroup(GroupLayout.LEADING)
				.add(gl_shell.createSequentialGroup()
					.add(gl_shell.createParallelGroup(GroupLayout.LEADING)
						.add(gl_shell.createSequentialGroup()
							.add(28)
							.add(lblNewLabel)
							.add(28)
							.add(text, GroupLayout.PREFERRED_SIZE, 187, GroupLayout.PREFERRED_SIZE))
						.add(gl_shell.createSequentialGroup()
							.add(28)
							.add(lblMtKhu)
							.add(56)
							.add(text_1, GroupLayout.PREFERRED_SIZE, 187, GroupLayout.PREFERRED_SIZE))
						.add(gl_shell.createSequentialGroup()
							.add(128)
							.add(btnGhiNh))
						.add(gl_shell.createSequentialGroup()
							.add(28)
							.add(lblNgnNg)
							.add(53)
							.add(combo, GroupLayout.PREFERRED_SIZE, 187, GroupLayout.PREFERRED_SIZE))
						.add(gl_shell.createSequentialGroup()
							.add(61)
							.add(btnCuHnh, GroupLayout.PREFERRED_SIZE, 67, GroupLayout.PREFERRED_SIZE)
							.add(28)
							.add(btnngNhp, GroupLayout.PREFERRED_SIZE, 74, GroupLayout.PREFERRED_SIZE)
							.add(33)
							.add(btnng, GroupLayout.PREFERRED_SIZE, 64, GroupLayout.PREFERRED_SIZE)))
					.add(36))
		);
		gl_shell.setVerticalGroup(
			gl_shell.createParallelGroup(GroupLayout.LEADING)
				.add(gl_shell.createSequentialGroup()
					.add(23)
					.add(gl_shell.createParallelGroup(GroupLayout.LEADING)
						.add(gl_shell.createSequentialGroup()
							.add(3)
							.add(lblNewLabel))
						.add(text, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.add(5)
					.add(gl_shell.createParallelGroup(GroupLayout.LEADING)
						.add(gl_shell.createSequentialGroup()
							.add(3)
							.add(lblMtKhu))
						.add(text_1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.add(5)
					.add(btnGhiNh)
					.add(5)
					.add(gl_shell.createParallelGroup(GroupLayout.LEADING)
						.add(gl_shell.createSequentialGroup()
							.add(4)
							.add(lblNgnNg))
						.add(combo, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
					.add(gl_shell.createParallelGroup(GroupLayout.LEADING)
						.add(gl_shell.createSequentialGroup()
							.add(9)
							.add(btnCuHnh, GroupLayout.PREFERRED_SIZE, 29, GroupLayout.PREFERRED_SIZE))
						.add(gl_shell.createSequentialGroup()
							.add(8)
							.add(btnngNhp, GroupLayout.PREFERRED_SIZE, 30, GroupLayout.PREFERRED_SIZE))
						.add(gl_shell.createSequentialGroup()
							.add(7)
							.add(btnng, GroupLayout.PREFERRED_SIZE, 31, GroupLayout.PREFERRED_SIZE))))
		);
		shell.setLayout(gl_shell);

	}

}
